﻿using Microsoft.Win32;
using System.ComponentModel;
using System.Drawing;
using System.Xml.Serialization;

namespace System.Windows.Forms
{
	public partial class ListViewEx : ListView
	{
		private ListViewItemExCollection newItems;

		[Description("Items"), Localizable(true), MergableProperty(false), Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
		[Editor(typeof(ListViewItemExCollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
		public new ListViewItemExCollection Items
		{
			get { if (newItems == null) newItems = new ListViewItemExCollection(this); return newItems; }
		}

		internal ListViewItemCollection BaseItems
		{
			get { return base.Items; }
		}

		private void OnHandleCreated_Items(EventArgs e)
		{
		}

		private void WmReflectNotify_Items(ref Message m)
		{
			var nm = m.GetLParam<NativeMethods.NMHDR>();
			/*if (nm.code == (int)NativeMethods.ListViewNotifications.ColumnDropDown)
			{
				var nmlv = m.GetLParam<NativeMethods.NMLISTVIEW>();
				var iCol = nmlv.iSubItem;
				NativeMethods.RECT rc = new NativeMethods.RECT();
				NativeMethods.SendMessage(HeaderHandle, (uint)NativeMethods.HeaderMessage.GetItemDropDownRect, (IntPtr)iCol, ref rc);
				OnColumnHeaderDropdown(new ColumnHeaderDropdownArgs() { Column = iCol, ColumnBounds = rc });
				if (this.Columns[iCol].DropDownContextMenu != null)
					this.Columns[iCol].DropDownContextMenu.Show(this, rc.X, rc.Bottom);
			}*/
		}

		/// <summary>
		/// Overrides <see cref="M:System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message@)" />.
		/// </summary>
		/// <param name="m">The Windows <see cref="T:System.Windows.Forms.Message" /> to process.</param>
		[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.LinkDemand, Flags = System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)]
		protected void WndProc_Items(ref Message m)
		{
			if (m.Msg == 0x7b) // WM_CONTEXTMENU
			{
			}
			else if (m.Msg == 0x204E) // WM_NOTIFY
			{
				WmReflectNotify_Items(ref m);
			}
		}
	}
}